<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>第一种头部</title>
    <link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/aui.css" />
    <style>
        html,
        body {
            width: 100%;
            min-height: 100%;
            background: #f7f7f7;
            line-height: 1;
        }
        /*修改头部标题*/

        .header_title {
            font-size: 0.9rem;
            font-weight: bold;
        }
        /*固定头部*/

        .header {
            background-color: #f7f7f7;
            border: none!important;
            z-index: 8!important;
        }
        /*头部右侧文字*/

        .right_txt {
            font-size: 0.7rem;
            color: #f23030;
        }
        /*头部左侧文字*/

        .left_txt {
            color: #999;
            font-size: 0.7rem;
        }
        /*遮罩*/

        .cover {
            position: fixed;
            margin-top: 25px;
            min-height: 2.25rem;
            width: 100vw;
            background-color: rgba(0, 0, 0, .6);
            top: 0;
            z-index: 20;
            display: none;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav header" id='header' style="padding-top:25px;">
        <a class="aui-pull-left aui-btn" onclick="close_win()">
            <span class="left_txt">取消</span>
        </a>
        <div class="aui-title header_title">第四种头部</div>
        <a class="aui-pull-right aui-btn" onclick="to_release()">
            <span class="right_txt">文本</span>
        </a>
    </header>


    <div class="cover"></div>
</body>
<script type="text/javascript" src="../../../script/api.js"></script>
<script type="text/javascript" src="../../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script type="text/javascript" src="../../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../../script/aui-toast.js"></script>
<script type="text/javascript">
    apiready = function() {

        //获取header的高度
        var oHeader = $api.byId("header");
        var headerH = $api.offset(oHeader).h;


        if (api.pageParam.type == "图文分享") {
            $('.right_txt').html(api.pageParam.title);
            $('.header_title').text("");
            api.openFrame({
                name: 'graphic_sharing',
                url: '../graphic_sharing.html',
                rect: {
                    x: 0,
                    y: headerH,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam: {
                    name: 'test'
                },
                bounces: true,
                bgColor: 'rgba(0,0,0,0)',
                vScrollBarEnabled: true,
                hScrollBarEnabled: true
            });

        } else if (api.pageParam.type == "商品分享") {
            $('.right_txt').html(api.pageParam.title);
            $('.header_title').text("");
            api.openFrame({
                name: 'shop_sharing',
                url: '../shop_sharing.html',
                rect: {
                    x: 0,
                    y: headerH,
                    w: 'auto',
                    h: 'auto'
                },
                pageParam: {
                    name: 'test'
                },
                bounces: true,
                bgColor: 'rgba(0,0,0,0)',
                vScrollBarEnabled: true,
                hScrollBarEnabled: true
            });
        } else if (api.pageParam.type == "定位") {
            $('.right_txt').html(api.pageParam.right_txt);
            $('.header_title').text("");

            // 定位当前的位置
            var bMap = api.require('bMap');
            bMap.getLocation({
                accuracy: '100m',
                autoStop: true,
                filter: 1
            }, function(ret, err) {
                if (ret.status) {
                    // 打开选择地址页面
                    api.openFrame({
                        name: 'chose_address',
                        url: '../chose_address.html',
                        rect: {
                            x: 0,
                            y: headerH,
                            w: 'auto',
                            h: 'auto'
                        },
                        pageParam: {
                            lon: ret.lon,
                            lat: ret.lat
                        },
                        bounces: true,
                        bgColor: 'rgba(0,0,0,0)',
                        vScrollBarEnabled: true,
                        hScrollBarEnabled: true
                    });
                } else {
                    // alert(err.code);
                }
            });
        }


    };


    // 关闭当前窗口
    function close_win() {
        api.closeWin({});
    }


    //点击发布按钮
    function to_release() {

        // 图文分享执行的方法
        if(api.pageParam.type=="图文分享"){
          api.execScript({
              frameName: 'graphic_sharing',
              script: 'graphic_sharing();'
          });
        }else if(api.pageParam.type=="商品分享"){
          api.execScript({
              frameName: 'shop_sharing',
              script: 'shop_sharing();'
          });
        }
    }


    // 添加以及移除遮罩
    function add_move(index){
      $('.cover').show();
      if(index==1){
        api.execScript({
            frameName: 'graphic_sharing',
            script: 'add_cover();'
        });
      }else{
        api.execScript({
            frameName: 'shop_sharing',
            script: 'add_cover();'
        });
      }



      setTimeout(function() {
          $('.cover').hide();
      }, 2000)
    }
</script>

</html>
